using System;

namespace JGSY.CMS.LowCode.Platform.Application.DTOs
{
    /// <summary>
    /// 权限路由映射数据传输对象
    /// </summary>
    public class PermissionRouteMappingDto
    {
        /// <summary>
        /// 主键ID
        /// </summary>
        public long Id { get; set; }
        
        /// <summary>
        /// 路径模式
        /// </summary>
        public string Path { get; set; } = string.Empty;
        
        /// <summary>
        /// HTTP方法
        /// </summary>
        public string Method { get; set; } = string.Empty;
        
        /// <summary>
        /// 权限代码
        /// </summary>
        public string PermissionCode { get; set; } = string.Empty;
        
        /// <summary>
        /// 映射名称
        /// </summary>
        public string? Name { get; set; }
        
        /// <summary>
        /// 描述
        /// </summary>
        public string? Description { get; set; }
        
        /// <summary>
        /// 优先级
        /// </summary>
        public int Priority { get; set; }
        
        /// <summary>
        /// 是否启用
        /// </summary>
        public bool IsActive { get; set; } = true;
        
        /// <summary>
        /// 来源
        /// </summary>
        public string Source { get; set; } = "Database";
        
        /// <summary>
        /// 分组
        /// </summary>
        public string? Group { get; set; }
        
        /// <summary>
        /// 排序
        /// </summary>
        public int SortOrder { get; set; }
        
        /// <summary>
        /// 备注
        /// </summary>
        public string? Remark { get; set; }
        
        /// <summary>
        /// 创建人ID
        /// </summary>
        public long? CreatedBy { get; set; }
        
        /// <summary>
        /// 创建人名称
        /// </summary>
        public string? CreatedByName { get; set; }
        
        /// <summary>
        /// 更新人ID
        /// </summary>
        public long? UpdatedBy { get; set; }
        
        /// <summary>
        /// 更新人名称
        /// </summary>
        public string? UpdatedByName { get; set; }
        
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreatedAt { get; set; }
        
        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime UpdatedAt { get; set; }
        
        /// <summary>
        /// 扩展属性
        /// </summary>
        public string? ExtendedProperties { get; set; }
    }

    /// <summary>
    /// 权限路由映射统计DTO
    /// </summary>
    public class PermissionRouteMappingStatisticsDto
    {
        /// <summary>
        /// 总数量
        /// </summary>
        public int TotalMappings { get; set; }
        
        /// <summary>
        /// 活跃数量
        /// </summary>
        public int ActiveMappings { get; set; }
        
        /// <summary>
        /// 分组数量
        /// </summary>
        public int GroupCount { get; set; }
        
        /// <summary>
        /// 按分组统计
        /// </summary>
        public Dictionary<string, int> GroupStatistics { get; set; } = new();
        
        /// <summary>
        /// 按HTTP方法统计
        /// </summary>
        public Dictionary<string, int> MethodStatistics { get; set; } = new();
        
        /// <summary>
        /// 按来源统计
        /// </summary>
        public Dictionary<string, int> SourceStatistics { get; set; } = new();
        
        /// <summary>
        /// 最近更新时间
        /// </summary>
        public DateTime? LastUpdated { get; set; }
    }

    /// <summary>
    /// 路径匹配测试结果DTO
    /// </summary>
    public class PathMatchTestResultDto
    {
        /// <summary>
        /// 测试路径
        /// </summary>
        public string TestPath { get; set; } = string.Empty;
        
        /// <summary>
        /// 测试方法
        /// </summary>
        public string TestMethod { get; set; } = string.Empty;
        
        /// <summary>
        /// 匹配的映射列表
        /// </summary>
        public List<PermissionRouteMappingDto> Matches { get; set; } = new();
        
        /// <summary>
        /// 最优匹配（优先级最高的）
        /// </summary>
        public PermissionRouteMappingDto? BestMatch { get; set; }
        
        /// <summary>
        /// 解析出的权限代码
        /// </summary>
        public string? ResolvedPermissionCode { get; set; }
    }
}
